//angular.module('userCenterModule',[])

/*app.controller('userCenterController',function ($scope, $http, $stateParams) {
    $scope.currentUser = $stateParams.user;
    console.log("stateParams: "+ $stateParams.user)
    console.log("currentUser:"+$scope.currentUser);
})*/
function userCenterController($scope, $http, $stateParams,$state) {
    //$scope.currentUser =$stateParams.user;
    $scope.accountName = $stateParams.accountName;
    $scope.password = $stateParams.password;
    $scope.user = null;
    $scope.goToEditPage = function () {
        $state.go('editUser',{accountName : $scope.accountName});
    };

    var getCurrentUser = function () {
        $http({
            url: '/userLogin/getCurrentUser',
            method: 'GET'
        }).success(function (response) {

            console.log("response: " + response);
            $scope.user = response;
           // $scope.jsonUser = JSON.stringify($scope.user);
            $scope.age = $scope.user.age;
            console.log("user.age" + $scope.age);

            if($scope.user == null){
                alert("用户名或者密码错误！");
                $state.go('login');
            }


        }).error(function (response) {
            alert('error')
        })
    };
    getCurrentUser();

    $scope.returnPhotoStart = function () {
        $state.go('photoStart');

    }

    /*
    var findUserByAccountName = function () {
        console.log("user's accountName: " + $scope.accountName);
        $scope.user = null;
        //var jsonUser = [];
        $http({

            url: '/userLogin/getUserByAccountName',
            method: 'GET',
            params: { "accountName": $scope.accountName , "password" : $scope.password}

        }).success(function (response) {

            console.log("response: " + response);
            $scope.user = response;
            $scope.jsonUser = JSON.stringify($scope.user);
            $scope.age = $scope.user.age;
            console.log("user.age" + $scope.age);

            if($scope.user == null){
                alert("用户名或者密码错误！");
                $state.go('login');
            }


        }).error(function (response) {
            alert('error')
        })

    };

    findUserByAccountName();
    */


 }

